package com.itheima.demo;

import java.util.Scanner;

public class TestDemp {

    public static void main(String[] arg){
        //准备这些设备的对象
        HouseholdAppliance[] jds = new HouseholdAppliance[4];
        jds[0] = new TV("电视", true);
        jds[1] = new Air("空调", true);
        jds[2] = new WashMachine("洗衣机", true);
        jds[3] = new Lamp("灯泡", true);
        //为每个设备制定开关功能
        //创建智能控制系统对象，控制开关
        SmartHomeControl smartHomeControl = SmartHomeControl.getInstance();
        smartHomeControl.printAllStatus(jds);
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("请输入1-4控制开关");
            String command = scanner.next();
            switch (command){
                case "1":
                    smartHomeControl.control(jds[0]);
                    break;
                case "2":
                    smartHomeControl.control(jds[1]);
                    break;
                case "3":
                    smartHomeControl.control(jds[2]);
                    break;
                case "4":
                    smartHomeControl.control(jds[3]);
                    break;
                case "exit":
                    System.out.println("退出程序");
                    return;
                case "all":
                    smartHomeControl.printAllStatus(jds);
                    break;
                default:
                    System.out.println("输入错误");
                    break;
            }
        }
    }
}
